import Network from '../utils/network';

export interface LoginResult {
  phone: string;
  verifyStatus: number;
  nickName: string;
  avatar: string;
}

export function loginWithPwd(
  phone: string,
  pwdHex: string,
): Promise<LoginResult> {
  return Network.post({
    url: '/app/user/login',
    data: {
      phone,
      password: pwdHex,
    },
  }).then(({data}) => ({
    phone: data.phone,
    verifyStatus: data.identity_status,
    nickName: data.nickname,
    avatar: data.avatar,
  }));
}
